package com.example.administrator.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import java.util.ArrayList;
import java.util.List;
import android.support.v7.widget.RecyclerView;

public class MainActivity extends AppCompatActivity {

    private List<Imagetext> imagetextList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
        android.support.v7.widget.RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
        GridLayoutManager layoutManager=new GridLayoutManager ( this,3 );
        recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
        recyclerView.setLayoutManager(layoutManager);
        RecyclerViewAdapter adapter = new RecyclerViewAdapter(imagetextList);
        recyclerView.setAdapter(adapter);
    }

    private void init() {
        for (int i = 0; i < 5; i++) {
            Imagetext a = new Imagetext("part one part one part one part one part one part one part one part one ", R.mipmap.ic_launcher);
            imagetextList.add(a);
            Imagetext b = new Imagetext("part two part two part two part two part two part two part two part two ", R.mipmap.ic_launcher);
            imagetextList.add(b);
            Imagetext c = new Imagetext("part three part three part three part three part three part three part three part three ", R.mipmap.ic_launcher);
            imagetextList.add(c);
            Imagetext d = new Imagetext("part four part four part four part four part four part four part four part four ", R.mipmap.ic_launcher);
            imagetextList.add(d);
            Imagetext e = new Imagetext("part five part five part five part five part five part five part five part five ", R.mipmap.ic_launcher);
            imagetextList.add(e);
            Imagetext f = new Imagetext("part six part six part six part six part six part six part six part six ", R.mipmap.ic_launcher);
            imagetextList.add(f);
        }
    }
}
